package com.grpcserver.service;

import com.grpcclient.api.CreateUserRequest;
import com.grpcclient.api.UserGrpc;
import com.grpcclient.api.UserInfo;
import com.grpcclient.api.UserReply;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;

import java.util.UUID;

/**
 * @author: LCG
 * @date: 2022-10-25 15:16:01
 * @description:
 **/
@GrpcService
@Slf4j
public class GrpcServerService extends UserGrpc.UserImplBase {

    public GrpcServerService() {
        System.out.println("==============");
    }

    @Override
    public void createUser(CreateUserRequest request, StreamObserver<UserReply> responseObserver) {
        log.info("收到GRPC请求参数:{}", request);

        UserReply.Builder userReplyBuilder = UserReply.newBuilder();
        userReplyBuilder.setMessage("success-ssssss");
        userReplyBuilder.setCode(99);
        userReplyBuilder.setData(
                UserInfo.newBuilder()
                        .setMobile("55555555555")
                        .setNickname("guoboren")
                        .build()
        );
        responseObserver.onNext(userReplyBuilder.build());
        responseObserver.onCompleted();
    }



}
